package com.net.wanjian.networkhospitalmanager.fragment.rotateorder;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.widget.TextView;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.bean.SearchMainRotateTeacherResult;
import com.net.wanjian.networkhospitalmanager.fragment.base.BaseFragment;
import com.net.wanjian.networkhospitalmanager.net.HttpUtil;
import com.net.wanjian.networkhospitalmanager.netstatus.NetUtils;
import com.net.wanjian.networkhospitalmanager.utils.PicassoUtil;
import com.net.wanjian.networkhospitalmanager.utils.SharedXmlUtil;
import com.net.wanjian.networkhospitalmanager.utils.URLDecoderUtil;
import com.net.wanjian.networkhospitalmanager.view.CircleImageView;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class RotateTeacherDoctorInfoFragment extends BaseFragment {
    private static final String ROTATE_TEACHER_BEAN = "rotate_teacher_bean";
    @BindView(R.id.rotate_teacher_doctor_head_iv)
    CircleImageView rotateTeacherDoctorHeadIv;
    @BindView(R.id.rotate_teacher_doctor_name_tv)
    TextView rotateTeacherDoctorNameTv;
    @BindView(R.id.rotate_teacher_doctor_department_tv)
    TextView rotateTeacherDoctorDepartmentTv;
    @BindView(R.id.rotate_teacher_doctor_phone_tv)
    TextView rotateTeacherDoctorPhoneTv;

    private SearchMainRotateTeacherResult.DataBean.UserIdentityListBean identityListBean;


    public RotateTeacherDoctorInfoFragment() {
        // Required empty public constructor
    }

    public static RotateTeacherDoctorInfoFragment getInstance(SearchMainRotateTeacherResult.DataBean.UserIdentityListBean d) {
        RotateTeacherDoctorInfoFragment fragment = new RotateTeacherDoctorInfoFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable(ROTATE_TEACHER_BEAN, d);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            identityListBean = (SearchMainRotateTeacherResult.DataBean.UserIdentityListBean) getArguments().getSerializable(ROTATE_TEACHER_BEAN);
        }
    }


    @Override
    protected void initView() {
        //加载图片
        PicassoUtil.loadImage(mContext,
                HttpUtil.getImageUrl(SharedXmlUtil.getInstance().getHospitalId(), URLDecoderUtil.getDecoder(identityListBean.getUserInfoID()), 2),
                R.mipmap.user, rotateTeacherDoctorHeadIv);
        //设置数据
        if (URLDecoderUtil.getDecoder(identityListBean.getPositionalTitles()).equals("")){
            rotateTeacherDoctorNameTv.setText(URLDecoderUtil.getDecoder(identityListBean.getUserInfoTrueName()+"   "+"无职称"));
        }else {
            rotateTeacherDoctorNameTv.setText(URLDecoderUtil.getDecoder(identityListBean.getUserInfoTrueName()+"   "+URLDecoderUtil.getDecoder(identityListBean.getPositionalTitles())));
        }
        if (URLDecoderUtil.getDecoder(identityListBean.getDepartmentName()).equals("")){
            rotateTeacherDoctorDepartmentTv.setText("科室："+"无科室");

        }else {
            rotateTeacherDoctorDepartmentTv.setText("科室："+URLDecoderUtil.getDecoder(identityListBean.getDepartmentName()));
        }
        if (URLDecoderUtil.getDecoder(identityListBean.getUserInfoPhone()).equals("")){
            rotateTeacherDoctorPhoneTv.setText("联系电话："+"无电话");
        }else {
            rotateTeacherDoctorPhoneTv.setText("联系电话："+URLDecoderUtil.getDecoder(identityListBean.getUserInfoPhone()));

        }
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_rotate_teacher_doctor_info;
    }

    @Override
    protected void initData() {

    }
}
